package com.qianfeng.day11.controller;

import com.qianfeng.day11.service.KillService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
public class KillController {
    @Resource
    private KillService killService;

    @RequestMapping("/kill")
    public String kill(Model model){
        String orderNumber = killService.kill();
        if (orderNumber == null){
            model.addAttribute("msg", "谢谢参与，下次再接再厉");
        }else {
            model.addAttribute("msg", "恭喜你秒杀成功，你的订单号为：" + orderNumber);
        }
        return "/result";
    }
}
